package com.flash.DayProcessing.service.impl;

import com.flash.DayProcessing.entity.BondsInterest;
import com.flash.DayProcessing.entity.CashInterest;
import com.flash.DayProcessing.entity.TowFees;
import com.flash.DayProcessing.mapper.AccrualOfIncomeMapper;
import com.flash.DayProcessing.service.AccrualOfIncomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AccrualOfIncomeServiceImpl implements AccrualOfIncomeService {
    @Autowired
    AccrualOfIncomeMapper accrualOfIncomeMapper;

    //余额*年利率/数量/计息期间

    @Override
    public List<CashInterest> selectCashInterest(String dateCashStock, int page, int limit) {
        HashMap map=new HashMap();
        if(dateCashStock!=null && !dateCashStock.equals("")){
            map.put("dateCashStock",dateCashStock);
        }else {
            map.put("dateCashStock","2022-01-22");
        }
        System.out.println("impl"+dateCashStock);
        map.put("page",(page-1)*limit);
        map.put("limit",limit);
        return accrualOfIncomeMapper.selectCashInterest(map);
    }

    @Override
    public int selectCashInterestCount() {
        return accrualOfIncomeMapper.selectCashInterestCount();
    }

    @Override
    public List<BondsInterest> selectBondsInterest(String dateStock, int page, int limit) {
        HashMap map=new HashMap();
        if(dateStock!=null && !dateStock.equals("")){
            map.put("dateStock",dateStock);
        }else {
            map.put("dateStock","2022-01-22");
        }

        map.put("page",(page-1)*limit);
        map.put("limit",limit);
        return accrualOfIncomeMapper.selectBondsInterest(map);
    }

    @Override
    public int selectBondsInterestCount() {
        return accrualOfIncomeMapper.selectCashInterestCount();
    }

    @Override
    public List<TowFees> selectTowFeesInterest(String dateCashStock, int page, int limit) {
        HashMap map=new HashMap();
        if(dateCashStock!=null && !dateCashStock.equals("")){
            map.put("dateCashStock",dateCashStock);
        }else {
            map.put("dateCashStock","2022-01-22");
        }
        map.put("page",(page-1)*limit+1);
        map.put("limit",limit*page);
        return accrualOfIncomeMapper.selectTowFeesInterest(map);
    }

    @Override
    public int selectTowFeesInterestCount() {
        return accrualOfIncomeMapper.selectTowFeesInterestCount();
    }
}
